class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        vector<int> hash(300);
        int size = s.size(), ans = 0;
        for(int l = 0, r = 0; r < size; ++r)
        {
            hash[s[r]]++;
            while(hash[s[r]] > 1) hash[s[l++]]--;
            ans = max(ans, r - l + 1);
        }
        return ans;
    }
};